<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    
</head>

<body>
    <div id="app">
        <form>
            <h2>新增商品</h2>
            名称：<input type="text" v-model="good.name"><br><br>
            价格：<input type="password" v-model="good.price"><br><br>
            <button @click.prevent="add">增加</button>
        </form>
    </div>


    <script>
        const { createApp } = Vue
        createApp({
            data() {
                return {
                    good:{
                        name:"",
                        price:"",
                        img:"images/kunkun.png"
                    }
                }
            },
            methods: {
                add(){
                    axios.post("http://127.0.0.1:8888/goods",this.good)
                    .then(res => {
                        window.location.href = "index.html"
                        
                    })
                }
            },
        }).mount("#app")
    </script>
</body>

</html>